.PHONY: all
all: modules lint test build

# ==============================================================================
# Includes

include hack/include/common.mk # make sure include common.mk at the first include line
include hack/include/tools.mk
include hack/include/go.mk
include hack/include/test.mk
include hack/include/release.mk

# ==============================================================================
# Usage

define USAGE_OPTIONS

Options:
  VERSION          The version information compiled into binaries.
                   The default is obtained from gsemver or git.
  PUBLISH          Whether to publish a release to Github. Default is 0.
                   This option is available when using: make release
  GITHUB_TOKEN     Token used to access Github.
                   This option is available when using: make release
  V                Set to 1 enable verbose build. Default is 0.
  DEBUG            Whether to generate debug symbols. Default is 0.
endef
export USAGE_OPTIONS

# ==============================================================================
# Targets

## build: build binary file.
.PHONY: build
build: modules
	@$(MAKE) go.build

## tag: generate release tag.
.PHONY: tag
tag:
	@$(MAKE) release.tag

## release: release a version.
.PHONY: release
release:
	@$(MAKE) release.run

## modules: add missing and remove unused modules.
.PHONY: modules
modules:
	@go mod tidy

## clean: remove all files that are generated by building.
.PHONY: clean
clean:
	@$(MAKE) go.clean

## lint: Check syntax and styling of go sources.
.PHONY: lint
lint:
	@$(MAKE) go.lint

## test: run unit test and get test coverage.
.PHONY: test
test:
	@$(MAKE) test.cover

## e2e: run e2e test.
.PHONY: e2e
e2e:
	@$(MAKE) test.e2e

## help: show help information.
.PHONY: help
help: Makefile
	@echo -e "\nUsage: make <TARGETS> <OPTIONS> ...\n\nTargets:"
	@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
	@echo "$$USAGE_OPTIONS"
